home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-21 | 1.0 KB | 81 lines | [TEXT/CWIE] |
- #include <iostream.h>
-
-
- //--------------------------------------- Root
-
- class Root
- {
- protected:
- short num;
-
- public:
- Root( short numParam );
- };
-
- Root::Root( short numParam )
- {
- num = numParam;
-
- cout << "Root constructor called\n";
- }
-
-
- //--------------------------------------- Base1
-
- class Base1 : public virtual Root
- {
- public:
- Base1();
- };
-
- Base1::Base1() : Root( 1 )
- {
- cout << "Base1 constructor called\n";
- }
-
-
- //--------------------------------------- Base2
-
- class Base2 : public virtual Root
- {
- public:
- Base2();
- };
-
- Base2::Base2() : Root( 2 )
- {
- cout << "Base2 constructor called\n";
- }
-
-
- //--------------------------------------- Derived
-
- class Derived : public Base1, public Base2
- {
- public:
- Derived();
- short GetNum();
- };
-
- Derived::Derived() : Root( 3 )
- {
- cout << "Derived constructor called\n";
- }
-
- short Derived::GetNum()
- {
- return( num );
- }
-
-
- //--------------------------------------- main()
-
- int main()
- {
- Derived myDerived;
-
- cout << "-------\n"
- << "num = " << myDerived.GetNum();
-
- return 0;
- }